class Solution {
public:
    double Power(double base, int exponent) {
    	if(base == 0)
    		return 0;
    	if(exponent == 0)
    		return 1.0;
    	double sum = 1;
    	bool belowZero = false;
    	if(exponent < 0)
    	{
    		exponent = -exponent;
    		belowZero = true;
    	}
    	while(exponent >= 1)
    	{
    		sum *= base;
    		--exponent;
    	}
    	if(belowZero)
    		return 1/sum;
    	return sum;
    }
};